
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/commonly-used-show.css" />
    <script type="text/javascript" src="approvalProcess/js/jquery.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap.js" ></script>
    <script type="text/javascript" src="approvalProcess/js/jquery.cookie.js"></script>

    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap-datetimepicker.min.css" />
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>


    <title>审批详情</title>

</head>
<body class="mybody">

<jsp:include page="theTopMenuUser.jsp" />




 <div class="container-fluid">
    <div class="row">


        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div id="applicat_modality" class="alert alert-success">


                                <div class="container">
        <h3 style="text-align: center">申请信息</h3>
        <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

        <div id="add_apply" class="container">
            <div class="form-group same-line">
                <label><b style="color: red">*&nbsp</b>学院：</label>
                <input type="text" id="name_college" class="form-control edit" placeholder="请输入学院">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>年级：</label>
                <input type="text" id="current_grade" class="form-control edit" placeholder="请输入年级">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>专业班级：</label>
                <input type="text" id="professional_class" class="form-control edit" placeholder="请输入专业班级">
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>学号：</label>
                <input type="text" id="student_number" class="form-control edit" placeholder="请输入学号" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="15">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>姓名：</label>
                <input type="text" id="user_name" class="form-control edit" placeholder="请输入姓名" maxlength="6">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>用户性别：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="user_sex" data-live-search="true" >
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>宿舍区：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="dormitory_area" data-live-search="true" >
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="至义A">至义A</option>
                    <option value="至义B">至义B</option>
                    <option value="尚雅A">尚雅A</option>
                    <option value="尚雅B">尚雅B</option>
                    <option value="尚雅C">尚雅C</option>
                    <option value="至仁A">至仁A</option>
                    <option value="至仁B">至仁B</option>
                    <option value="至仁C">至仁C</option>
                    <option value="清雅A">清雅A</option>
                    <option value="清雅B">清雅B</option>
                    <option value="清雅C">清雅C</option>
                    <option value="清雅D">清雅D</option>
                </select>
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>宿舍号：</label>
                <input type="text" id="dormitory_no" class="form-control edit" placeholder="请输入宿舍号" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="5">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>学生类型：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="student_type" data-live-search="true" >
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="硕士生">硕士生</option>
                    <option value="本科生">本科生</option>
                </select>
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>本人联系方式：</label>
                <input type="text" id="user_tel" class="form-control edit" placeholder="请输入本人联系方式" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>出校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="start_time">
                    <input id="start_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden" />
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>返校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="end_time">
                    <input id="end_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden" />
            </div>

            <div class="form-group same-line">
                <label >出行方式：</label>
                <input type="text" id="trip_mode" class="form-control edit" placeholder="公交车/出租车/步行/地铁" maxlength="20" >
            </div>

            <div class="form-group same-line-left">
                <label >目的地：</label>
                <input type="text" id="destination" class="form-control edit" placeholder="请输入目的地" maxlength="20">
            </div>

            <div class="form-group same-line">
                 <label ><b style="color: red">*&nbsp</b>申请出校原因：</label>
                <textarea id="reasons_school" style="width:500px; height:124px; resize: none;" placeholder="请在此填写出校原因" class="form-control edit" rows="3" cols="50"></textarea>
            </div>

            <div class="form-group same-line-left">
                <label >出行路线：</label>
                <input type="text" id="travel_route" style="width: 500px" class="form-control edit" placeholder="请输入出行路线" maxlength="40">
            </div>


        </div>

</div>

                            </div>



                            <div id="applicat_modalitytwo" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">辅导员审核建议</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">


                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>辅导员姓名：</label>
                                            <input type="text" id="counsellor_name" class="form-control edit" placeholder="请输入辅导员姓名" maxlength="6">
                                    </div>

                                        <div class="form-group same-line-left">
                                     <label ><b style="color: red">*&nbsp</b>辅导员审批结果：</label>
                                        <select style="font-size:14px" class="form-control edit" title="请选择" id="counsellor_agree_state" data-live-search="true" >
                                            <option value="" disabled selected hidden>请选择</option>
                                            <option value="同意">同意</option>
                                            <option value="不同意">不同意</option>
                                        </select>
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label >辅导员审批意见：</label>
                                        <textarea id="counsellor_audit_recommen" style="height:124px; resize: none;" placeholder="请在此填写审批建议" class="form-control edit" rows="3" cols="50"></textarea>
                                    </div>

                                    </div>

                                </div>

                            </div>




                            <div id="applicat_modalitythree" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">院领导审核建议</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">
                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>院领导姓名：</label>
                                            <input type="text" id="leaders_name" class="form-control edit" placeholder="请输入院领导姓名" maxlength="6">
                                    </div>

                                        <div class="form-group same-line-left">
                                        <label ><b style="color: red">*&nbsp</b>院审批结果：</label>
                                        <select style="font-size:14px" class="form-control edit" title="请选择" id="leaders_agree_state" data-live-search="true" >
                                            <option value="" disabled selected hidden>请选择</option>
                                            <option value="同意">同意</option>
                                            <option value="不同意">不同意</option>
                                        </select>
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label >院审批意见：</label>
                                        <textarea id="leaders_audit_recommen" style=" height:124px; resize: none;" placeholder="请在此填写审批建议" class="form-control edit" rows="3" cols="50"></textarea>
                                    </div>

                                    </div>


                                </div>

                            </div>

                            <div id="applicat_modalityfoure" class="alert alert-success">
                                <div class="container">
                                    <h3 style="text-align: center">校领导审核建议</h3>
                                    <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

                                    <div class="container">
                                        <div class="form-group same-line">
                                            <label ><b style="color: red">*&nbsp</b>校领导姓名：</label>
                                            <input type="text" id="school_name" class="form-control edit" placeholder="请输入校领导姓名" maxlength="6">
                                    </div>

                                        <div class="form-group same-line-left">
                                        <label ><b style="color: red">*&nbsp</b>校审批结果：</label>
                                        <select style="font-size:14px" class="form-control edit" title="请选择" id="school_agree_state" data-live-search="true" >
                                            <option value="" disabled selected hidden>请选择</option>
                                            <option value="同意">同意</option>
                                            <option value="不同意">不同意</option>
                                        </select>
                                    </div>

                                    <div class="form-group same-line-left">
                                        <label >校审批意见：</label>
                                        <textarea id="school_audit_recommen" style=" height:124px; resize: none;" placeholder="请在此填写审批建议" class="form-control edit" rows="3" cols="50"></textarea>
                                    </div>

                                    </div>


                                </div>

                            </div>


                            <div class="container">
                                    <div style="margin-top: 50px" class="form-group text-center same-line-clear">
                                        <input id="operation_status" type="button" value="重新申请" class="btn btn-primary" onclick="updateApply()">
                                        <input type="reset" value="重置" class="btn btn-danger interval" onclick="reset()">
                                    </div>

                                    <div class="text-center">
                                        <div style="margin-top: 20px;">
                                            <span id="user_messge" style="font-size:18px; color: red;"></span>
                                        </div>
                                    </div>

                                </div>





                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>


<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }

    if ("1" === "${param.type}"){
        modality1();
        $("#applicat_modalitytwo").hide();
        $("#applicat_modalitythree").hide();
        $("#applicat_modalityfoure").hide();
    }else if ("2" === "${param.type}"){
        modality1();
        $("#applicat_modalitythree").hide();
        $("#applicat_modalityfoure").hide();
    }else if ("3" === "${param.type}"){
        modality1();
        $("#applicat_modalityfoure").hide();
    } else if ("4" === "${param.type}"){
        modality2();
    }else if ("5" === "${param.type}"){
        modality3();
    }

    function modality1(){
        $("#applicat_modality").addClass("alert alert-warning");
        $("#applicat_modalitytwo").addClass("alert alert-warning");
        $("#applicat_modalitythree").addClass("alert alert-warning");
        $("#applicat_modalityfoure").addClass("alert alert-warning");
    }

    function modality2(){
        $("#applicat_modality").addClass("alert alert-success");
        $("#applicat_modalitytwo").addClass("alert alert-success");
        $("#applicat_modalitythree").addClass("alert alert-success");
        $("#applicat_modalityfoure").addClass("alert alert-success");
    }

    function modality3(){
        $("#applicat_modality").addClass("alert alert-danger");
        $("#applicat_modalitytwo").addClass("alert alert-danger");
        $("#applicat_modalitythree").addClass("alert alert-danger");
        $("#applicat_modalityfoure").addClass("alert alert-danger");
    }


    function studently(){

        $("#counsellor_name").attr("readOnly",true);
        $("#counsellor_agree_state").attr("disabled",true);
        $("#counsellor_audit_recommen").attr("readOnly",true);

        $("#leaders_name").attr("readOnly",true);
        $("#leaders_agree_state").attr("disabled",true);
        $("#leaders_audit_recommen").attr("readOnly",true);

        $("#school_name").attr("readOnly",true);
        $("#school_agree_state").attr("disabled",true);
        $("#school_audit_recommen").attr("readOnly",true);

    }


    window.onload = function(){
        queryApplyInfo();
        studently();
    }


    function queryApplyInfo(){
        var postUrl = "${pageContext.request.contextPath}/queryApplication";
        var str = {
            "myApproval": {
                "id": "${param.id}",
                "userLevel" : userdt.result.userLevel
            },
            "id": "${param.id}",
            "accessStatus": "${param.type}"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#user_messge").text(data.msg);
                }else {
                    initApply(data);
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

    function initApply(data){
        $("#name_college").val(data.result.userReplenish.belongsCollege);
        $("#current_grade").val(data.result.userReplenish.belongsGrade);
        $("#professional_class").val(data.result.userReplenish.belongsClass);
        $("#student_number").val(data.result.teacherStudentNumber);
        $("#user_name").val(data.result.userName);
        $("#user_sex").val(data.result.userSex);
        $("#dormitory_area").val(data.result.dormitoryArea);
        $("#dormitory_no").val(data.result.dormitoryNumber);
        $("#student_type").val(data.result.studentType);
        $("#user_tel").val(data.result.contactNumber);
        $("#start_time").val(data.result.startTime);
        $("#end_time").val(data.result.endTime);
        $("#trip_mode").val(data.result.tripMode);
        $("#destination").val(data.result.destination);
        $("#reasons_school").val(data.result.pursueReason);
        $("#travel_route").val(data.result.travelRoute);


        if (data.result.myApprovalList.length !== 0){
            for (var k = 0; k < data.result.myApprovalList.length; k++){
                if (data.result.myApprovalList[k].userLevel === "1"){
                    $("#counsellor_name").val(data.result.myApprovalList[k].nameApproval);
                    $("#counsellor_agree_state").val(data.result.myApprovalList[k].approvalResult);
                    $("#counsellor_audit_recommen").val(data.result.myApprovalList[k].approvalAdvice);

                }else if (data.result.myApprovalList[k].userLevel === "3"){
                    $("#leaders_name").val(data.result.myApprovalList[k].nameApproval);
                    $("#leaders_agree_state").val(data.result.myApprovalList[k].approvalResult);
                    $("#leaders_audit_recommen").val(data.result.myApprovalList[k].approvalAdvice);

                }else if (data.result.myApprovalList[k].userLevel === "4"){
                    $("#school_name").val(data.result.myApprovalList[k].nameApproval);
                    $("#school_agree_state").val(data.result.myApprovalList[k].approvalResult);
                    $("#school_audit_recommen").val(data.result.myApprovalList[k].approvalAdvice);

                }
            }
        }

    }

    function updateApply(){
        var mNameCollege = $("#name_college").val();
        var mCurrentGrade = $("#current_grade").val();
        var mProfessionalClass = $("#professional_class").val();
        var mStudentNumber = $("#student_number").val();
        var mUserName = $("#user_name").val();
        var mUserSex = $("#user_sex").val();
        var mDormitoryArea = $("#dormitory_area").val();
        var mDormitoryNo = $("#dormitory_no").val();
        var mStudentType = $("#student_type").val();
        var mUserTel = $("#user_tel").val();
        var mStartTime = $("#start_time").val();
        var mEndTime = $("#end_time").val();
        var mTripMode = $("#trip_mode").val();
        var mDestination = $("#destination").val();
        var mReasonsSchool = $("#reasons_school").val();
        var mTravelRoute = $("#travel_route").val();

        if ($.isEmptyObject(mNameCollege)){
            $("#user_messge").text("学院不能为空");
            return false;
        }else if ($.isEmptyObject(mCurrentGrade)){
            $("#user_messge").text("年级不能为空");
            return false;
        }else if ($.isEmptyObject(mProfessionalClass)){
            $("#user_messge").text("专业班级不能为空");
            return false;
        }else if ($.isEmptyObject(mStudentNumber)){
            $("#user_messge").text("学号不能为空");
            return false;
        }else if ($.isEmptyObject(mUserName)){
            $("#user_messge").text("姓名不能为空");
            return false;
        }else if ($.isEmptyObject(mUserSex)){
            $("#user_messge").text("用户性别不能为空");
            return false;
        }else if ($.isEmptyObject(mDormitoryArea)){
            $("#user_messge").text("宿舍区不能为空");
            return false;
        }else if ($.isEmptyObject(mDormitoryNo)){
            $("#user_messge").text("宿舍号不能为空");
            return false;
        }else if ($.isEmptyObject(mStudentType)){
            $("#user_messge").text("学生类型不能为空");
            return false;
        }else if ($.isEmptyObject(mUserTel)){
            $("#user_messge").text("联系方式不能为空");
            return false;
        }else if ($.isEmptyObject(mStartTime)){
            $("#user_messge").text("出校时间不能为空");
            return false;
        }else if ($.isEmptyObject(mEndTime)){
            $("#user_messge").text("出校原因不能为空");
            return false;
        }else if ($.isEmptyObject(mReasonsSchool)){
            $("#user_messge").text("出校原因不能为空");
            return false;
        }else {
            $("#user_messge").text("");
        }


        var postUrl = "${pageContext.request.contextPath}/updateApplication";
        var str = {
            "myApproval": {
                "id": "${param.id}",
                "approvalStatus": "1",
                "nameApproval": "",
                "approvalResult": "",
                "approvalAdvice": ""
            },
            "id": "${param.id}",
            "accessStatus": "1",

            "teacherStudentNumber": mStudentNumber,
            "userName": mUserName,
            "userSex": mUserSex,
            "contactNumber": mUserTel,
            "studentType": mStudentType,
            "startTime": mStartTime,
            "endTime": mEndTime,
            "destination": mDestination,
            "tripMode": mTripMode,
            "pursueReason": mReasonsSchool,
            "travelRoute": mTravelRoute,
            "dormitoryArea": mDormitoryArea,
            "dormitoryNumber": mDormitoryNo
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#user_messge").text(data.msg);
                }else {


                    location.href = "${pageContext.request.contextPath}/myApplication?type=1";
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }


    function reset(){
        var addUser = document.getElementById("add_apply");
        var ipts = addUser.getElementsByTagName("input");
        for (var i = 0; i < ipts.length; i++){
            ipts[i].value = "";
        }
    }


    //加载时间控件
    $('.form_datetime').datetimepicker({
        //默认语言
        language: 'zh-CN',
        //默认选择格式
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true,
        todayBtn: true,
        startView: 2,
    });


</script>

</body>
</html>
</span>